import { login } from '@/api/user'
import { setToken, getToken, removeToken } from '@/utils/auth'

export default {
  namespaced: true,
  state: {
    token: getToken(),
    suntoken: ''
  },
  mutations: {
    setToken(state, token) {
      state.token = token
      setToken(token)
    },
    removeToken(state) {
      state.token = null
      removeToken()
    },
    suntokens(state, sum) {
      state.suntoken = sum
    }
  },
  actions: {
    async login(context, data) {
      const result = await login(data)
    }
    // async login({ commit }, data) {
    //   const res = await login(data)
    //   // console.log(res)
    //   commit('setToken', res)
    // }
  }
}
